using Greg.XmlEditor.Business;
using Greg.XmlEditor.Model;

namespace Greg.XmlEditor.Presentation.Presenters
{
	public class StylePresenter : ChildDocumentPresenterBase
	{
		private readonly Style style;
		private readonly IDocumentService documentService;

		public StylePresenter(Style style, DocumentPresenter document, IDocumentService documentService)
			: base(style, document)
		{
			this.style = style;
			this.documentService = documentService;
		}

		public override void Open(string fileName)
		{
			this.documentService.Load(this.style, fileName);
			this.RefreshProperties();
		}

		public override void Save(string fileName)
		{
			this.style.Text = this.Text;
			this.documentService.Save(this.style, fileName);
			this.FullPath = fileName;
			this.RefreshProperties();
		}
	}
}